import { reqCategoryList ,reqBannerList} from "@/api";

const state ={
    categoryList :[],
    bannerList:[]
}

const mutations={
    REVICE_CATEGORYLIST(state,categoryList){
        state.categoryList = categoryList
    },
    REVICE_NANNERLIST(state,bannerList){
        state.bannerList = bannerList
    }
}

const actions ={
    async getCategoryList({commit}){
        let result = await reqCategoryList()
        if(result && result.code ===200){
            commit("REVICE_CATEGORYLIST",result.data)
        }
    },
    //获取首页轮播图数据
    async getBannerList({commit}){
        let result = await reqBannerList()
        console.log(result)
        if(result && result.code ===200){
            commit("REVICE_NANNERLIST",result.data)
        }
    }
}

const getters ={

}

export default {
    state,
    mutations,
    actions,
    getters
}
